package validjson;

import java.util.HashMap;
import java.util.Map;

public class SchemaBuilder extends Schema {
    private Map<String, Object> localSchemaMap;

    public static SchemaBuilder schema(String key, Object value) {
        return new SchemaBuilder(MapBuilder.map(key, value));
    }

    public static SchemaBuilder schema() {
        return new SchemaBuilder(new HashMap<String, Object>());
    }

    private SchemaBuilder(Map<String, Object> schemaMap) {
        super(schemaMap);
        this.localSchemaMap = schemaMap;
    }

    public SchemaBuilder with(String key, Object value) {
        localSchemaMap.put(key, value);
        return new SchemaBuilder(localSchemaMap);
    }

    public Map<String, Object> asMap() {
        return localSchemaMap;
    }
}
